package com.edu.chat.web.controller;

import com.edu.chat.web.common.model.R;
import com.edu.chat.web.controller.vo.ArticleVO;
import com.edu.chat.web.service.CsArticleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: KQAIA
 * @description:
 * @author: 无恙
 * @create: 2025-03-21 10:46
 **/

@RestController
@RequestMapping("/chat/article")
@Slf4j
public class ArticleController {

	@Autowired
	private CsArticleService csArticleService;


	//新建文章
	@RequestMapping("/create")
	public R<?> createArticle(@RequestBody @Validated ArticleVO articleVO) {
		return csArticleService.createArticle(articleVO);
	}

	//更新文章
	@RequestMapping("/update")
	public R<?> updateArticle(@RequestBody @Validated ArticleVO articleVO) {
		return csArticleService.updateArticle(articleVO);
	}

	//删除文章
	@RequestMapping("/delete/{id}")
	public R<?> deleteArticle(@PathVariable("id") String id) {
		return csArticleService.deleteArticle(id);
	}

	//查询文章详情
	@RequestMapping("/query/{id}")
	public R<?> queryArticle(@PathVariable("id") String id) {
		return csArticleService.getArticleById(id);
	}



}
